const popup = document.querySelector('.popup-greet')
const startBtn = document.getElementById('start')
const mus = document.getElementById('mus')
const musControl = document.getElementById('mus-control')
const ions = document.getElementsByClassName('ion')

mus.volume = 0.1

function musicPlay() {
	mus.play()
	if (!mus.paused) {
		for (let i = 0; i < ions.length; i++) {
			ions[i].classList.add('ion-play')
		}
	}
	musControl.addEventListener('click', playerControl)
}

function playerControl() {
	startBtn.removeEventListener('click', musicPlay)
	if (mus.paused) {
		mus.play()
		for (let i = 0; i < ions.length; i++) {
			ions[i].classList.add('ion-play')
		}
	} else {
		mus.pause()
		for (let i = 0; i < ions.length; i++) {
			ions[i].classList.remove('ion-play')
		}
	}
}

startBtn.addEventListener('click', () => {
	popup.classList.add('popup-greet-remove')
	setTimeout(() => {
		popup.remove()
	}, 2000)
	musicPlay()
})
